What marks are being used? What variables are mapped to which properties?
The marks being used are bars. The variable population is mapped to color and height/position—the X and Y Coordinates map spatial locations along the river’s course. The height of the bars represents population density. The color also represents population density with warmer colors (like orange and yellow) showing higher population density and darker colors (like purple) for lower density. Annotations: Text labels for key locations (Delhi, Agra, Prayagraj) help orient viewers geographically.
What is the main story of this graphic?
The main story that the Graphic is trying to convey is the population density along the Yamuna River. The graph highlights how density increases near major urban centers (like Delhi and Prayagraj) and is lower in other areas. It emphasizes the spatial relationship between the river and human settlements.
What makes it a good graphic?
The graph has clear visualizations. The height and color mapping make population density visually intuitive and stand out more. The graph uses annotations to give the readers contextual information for significant locations to provide spatial awareness. The 3D perspective effectively highlights density variations and is intuitive. The minimal background helps focus attention on the data, without much disturbance.
What features do you think you would know how to implement in Vega-Lite?
I think I would be able to use the bin feature to bin each population density. I would also be able to map the colors based on population density values. I could attempt to put labels and city names on my graph, but I wouldn’t know how to put arrows and make sure that the city names are right where I want them to be.
Are there any features of the graphic that you would not know how to do in Vega-Lite? If so, list them.
I don’t think I would be able to lay my data over a geographical map like what the graph shows. Putting the labels at certain specific area would be challenging. I’m not sure if I am able to make a 3-D graph either since the graph above uses x,y, and z.
Exercise 2
library(altair)library(vegawidget)
Attaching package: 'vegawidget'
The following objects are masked from 'package:altair':
JS, renderVegawidget, vegawidgetOutput, vw_as_json
library(readr)library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
library(vegalite)
Attaching package: 'vegalite'
The following object is masked from 'package:altair':
JS
library(lubridate)
Attaching package: 'lubridate'
The following objects are masked from 'package:base':
date, intersect, setdiff, union
library(vegabrite)
Attaching package: 'vegabrite'
The following objects are masked from 'package:altair':
renderVegawidget, vegawidgetOutput, vw_as_json
Rows: 2922 Columns: 11
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): location, weather
dbl (8): precipitation, temp_max, temp_min, wind, year, month, day, day_of_...
date (1): date
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
vl_chart(width =800, height =400) |>vl_mark_line() |>vl_encode_x("date:T", title ="Date") |>vl_encode_y("temp_max:Q", title ="High Temperature") |>vl_add_data(seattle_weather) |>vl_add_properties(title ="High Temperature in Seattle Each Day")
weather_data <- weather_data %>%mutate(day_of_year =yday(date), year =factor(year(date)))vl_chart(width =800, height =400) |>vl_mark_line() |>vl_encode_x("day_of_year:O", title ="Day of the Year") |>vl_encode_y("temp_max:Q", title ="High Temperature") |>vl_encode_color("year:N", title ="Year") |>vl_add_data(weather_data) |>vl_add_properties(title ="High Temperature in Seattle Each Day over Years")
#trying to fix the x-axis...weather_data <- weather_data %>%mutate(year =year(date))vl_chart(width =800, height =400) |>vl_mark_line() |>vl_encode_x("date:T", title ="Date") |>vl_encode_y("temp_max:Q", title ="High Temperature") |>vl_encode_color("year:N", title ="Year") |>vl_add_data(weather_data) |>vl_add_properties(title ="High Temperature in Seattle Each Day (Separated by Year)")